<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>三尺山教育信息咨询有限公司后台管理系统</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="../../jslib/jquery-easyui-1.3.1/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../../jslib/jquery-easyui-1.3.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../jslib/jquery-easyui-1.3.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../jslib/tools.js"></script>
<link rel="stylesheet" href="../../jslib/jquery-easyui-1.3.1/themes/default/easyui.css" type="text/css"></link>
<link rel="stylesheet" href="../../jslib/jquery-easyui-1.3.1/themes/icon.css" type="text/css"></link>
<style type="text/css">
.myBut {
	border: 1px solid #00FF99;
	background-color: #CCE8CF;
}
</style>
<script type="text/javascript" charset="utf-8">
	var baseUrl = '${pageContext.request.contextPath}';
	var moduls_detContent_propertyGrid;
	$(function() {
		moduls_detContent_propertyGrid = $('#moduls_detContent_propertyGrid').propertygrid({
			url : baseUrl + '/adAction!get.action',
			showGroup : true,
			scrollbarSize : 0,
			fit : true,
			groupField : 'page',
			fitColumns : false,
			border : false,
			toolbar : [ {
				text : '展开',
				iconCls : 'icon-redo',
				handler : function() {
					var node = $('#moduls_detContent_propertyGrid').propertygrid('getSelected');
					if (node) {
						$('#moduls_detContent_propertyGrid').propertygrid('expandGroup', node.cid);
					} else {
						$('#moduls_detContent_propertyGrid').propertygrid('expandGroup');
					}
				}
			}, '-', {
				text : '折叠',
				iconCls : 'icon-undo',
				handler : function() {
					var node = $('#moduls_detContent_propertyGrid').propertygrid('getSelected');
					if (node) {
						$('#moduls_detContent_propertyGrid').propertygrid('collapseGroup', node.cid);
					} else {
						$('#moduls_detContent_propertyGrid').propertygrid('collapseGroup');
					}
				}
			}, '-', {
				text : '刷新',
				iconCls : 'icon-reload',
				handler : function() {
					$('#moduls_detContent_propertyGrid').propertygrid('load');
				}
			} ],
			columns : [ [ {
				title : 'ID',
				field : 'id',
				width : 50,
				hidden : true
			}, {
				title : '广告栏位',
				field : 'place',
				width : 150
			}, {
				title : '图片名称',
				field : 'imgName',
				width : 300
			}, {
				title : '链接地址',
				field : 'link',
				width : 300
			}, {
				field : 'action',
				title : '操作',
				width : 100,
				formatter : function(value, row, index) {
					return '<img onclick="modify(' + row.id + ',\''+row.link+'\', \''+row.imgName+'\')" title="修改" alt="修改" src="'+baseUrl+'/jslib/jquery-easyui-1.3.1/themes/icons/book_edit.png">&nbsp;&nbsp;<a href="javascript:void(0)" onclick="queryImg(\'' + row.imgName + '\')" ><img title="查看图片" src="'+baseUrl+'/jslib/jquery-easyui-1.3.1/themes/icons/zoom.png"></a>';
				}
			} ] ]
		});

		$('#modifyDiv').dialog({
			title : '修改上传图片',
			width : 400,
			height : 200,
			closed : true,
			closable : false,
			modal : true,
			buttons : [ {
				text : '保存',
				iconCls : 'icon-edit',
				handler : function() {
					$('#adFormId').form('submit', {
						url : '${pageContext.request.contextPath}/adAction!modify.action',
						success : function(result) {
							try {
								var r = $.parseJSON(result);
								if (r.success) {
									$('#modifyDiv').dialog('close');
									$('#moduls_detContent_propertyGrid').propertygrid('load');
								}
								$.messager.show({
									title : '提示',
									msg : r.msg
								});
							} catch (e) {
								$.messager.alert('提示', result);
							}
						}
					});
				}
			}, {
				text : '取消',
				iconCls : 'icon-edit',
				handler : function() {
					$('#modifyDiv').dialog('close');
				}
			} ]
		});
	});
	
	function queryImg(img) {
		window.open(baseUrl+'/images/AdImg/'+img);
	}

	function modify(id, link, imgName) {
		$('#modifyDiv').dialog('open');
		$("#adFormId input[name=id]").val(id);
		$("#adFormId input[name=link]").val(link);
		$("#adFormId input[name=imgName]").val(imgName);
	}

	var moduls_detContent_addFun_PositionComboBoxData;
</script>
</head>
<body>
	<table id="moduls_detContent_propertyGrid"></table>
	<div id="modifyDiv">
	<br/>
		<form action="" id="adFormId" method="post" enctype="multipart/form-data">
		<input type="hidden" name="id">
		<table>
			<tr>
				<th style="font-weight: normal;width: 100px;">图片名称：</th>
				<td><input type="text" readonly="readonly" name="imgName" /></td>
			</tr>
			<tr>
				<th style="font-weight: normal;width: 100px;">图片链接：</th>
				<td><input type="text" name="link" /></td>
			</tr>
			<tr>
				<th style="font-weight: normal;width: 100px;">广告图片：</th>
				<td><input type="file" name="img" /></td>
			</tr>
		</table>
		</form>
	</div>
</body>
</html>